//自定义函数管理器
//本文件由：贺镇涛（2021300004071）负责
#pragma once
#include<string>
#include<vector>
#include"SLLList.h"
#include"BasicToys.h"

class FunctionStoreHouse : public SLList//量类，提供常量和变量查找，添加
{
public:
	FunctionStoreHouse()
	{
		size = 0;
		head = tail = NULL;
	}
    std::string get_value(const std::string& name, const std::string& variate, vector<string> var);
    std::string get_value(const std::string& name, const std::string& variate);
	~FunctionStoreHouse();
};
inline std::string FunctionStoreHouse::get_value(const std::string& name, const std::string& variate, vector<string> x_var)
{
	string temp = *get_valuePTR(name);
    if(x_var.size()==0)
    {
        x_var.push_back("x");
    }
	for(int i=0;i<=x_var.size()-1;i++)
	{
	temp = Replace_All(temp,x_var[0],variate);
	}
	return basic("{" +temp+"}");
}
inline std::string FunctionStoreHouse::get_value(const std::string& name, const std::string& variate)
{
    string temp = *get_valuePTR(name);
    temp = Replace_All(temp,"x",variate);
    return basic("{" +temp+"}");
}
FunctionStoreHouse::~FunctionStoreHouse()
{
	for (SLLNode* p; !isEmpty();)
	{
		p = head->next;
		delete head;                    //head变为野指针
		head = p;
	}
}
